//
//  AboutViewController.m
//  
//
//  Created by  yunshao on 2018/2/26.
//

#import "AboutViewController.h"
#import "pch.h"

@interface AboutViewController ()<UITableViewDelegate,UITableViewDataSource>{
    NSInteger  count ;
}
@property(nonatomic,strong)UIView * backView;
@property(nonatomic,strong)UIButton * backButton;               //返回按钮
@property(nonatomic,strong)UILabel * titleLable;                //标题
@property(nonatomic,strong)UITableView * myTableView;
@property(nonatomic,strong)UIButton * addButton;


@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addMianView];
    
}




-(void)addMianView{
    _backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, DSDevice_W, DSFixedPX(110))];
    _backView.backgroundColor = DSColorWithHex(0x3279ca);
    _backView.userInteractionEnabled = YES;
    [self.view addSubview:_backView];
    
    _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _backButton.frame = CGRectMake(DSFixedPX(20), DSFixedPX(40), DSFixedPX(40), DSFixedPX(40));
    [_backButton setImage:[UIImage imageNamed:@"title_back"] forState:UIControlStateNormal];
    [_backButton addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [_backView addSubview:_backButton];
    _titleLable = [[UILabel alloc]initWithFrame:CGRectMake(DSFixedPX(40), DSFixedPX(40), DSDevice_W - DSFixedPX(80), DSFixedPX(50))];
    _titleLable.text = @"关于我们";
    _titleLable.textAlignment = NSTextAlignmentCenter;
    _titleLable.font = DSFontSize(16);
    _titleLable.textColor = DSColorWithHex(0xffffff);
    [_backView addSubview:_titleLable];
    
     count = 1;
    
    _myTableView= [[UITableView alloc]initWithFrame:CGRectMake(0, DSFixedPX(120), DSDevice_W, DSFixedPX(150) *count) style:UITableViewStylePlain];
    
    _myTableView.delegate = self;
    _myTableView.dataSource = self;
    _myTableView.rowHeight = DSFixedPX(150);
    [self.view addSubview:_myTableView];
   
    
    _addButton= [UIButton buttonWithType:UIButtonTypeCustom];
    _addButton.frame = CGRectMake(DSFixedPX(20), CGRectGetMaxY(_myTableView.frame), DSDevice_W - DSFixedPX(40), DSFixedPX(50) );
    _addButton.backgroundColor = [UIColor redColor];
    [_addButton addTarget:self action:@selector(addButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_addButton];
    
}

-(void)addButtonClicked{
    if (count > 6) {
        [SVProgressHUD showErrorWithStatus:@"最多6哥"];
    }else{
        count = count + 1;
    }
    _myTableView.frame =CGRectMake(DSFixedPX(20), DSFixedPX(120), DSDevice_W - DSFixedPX(40), DSFixedPX(150) * count);
    _addButton.frame = CGRectMake(DSFixedPX(20), CGRectGetMaxY(_myTableView.frame), DSDevice_W - DSFixedPX(40), DSFixedPX(50) );
    [_myTableView reloadData];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return count;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"第%ld行",(long)indexPath.row];
    cell.backgroundColor = [UIColor blueColor];
    return cell;
}

-(void)backButtonClicked{
    [self dismissViewControllerAnimated:YES completion:^{
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
